home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / SPR5 / CONVERT / CONVERT.DOC next >
Encoding:
Text File  |  1996-05-27  |  5.0 KB  |  113 lines

  1.            WGT Sprite Editor Conversion Utilities
  2.                    Copyright 1996 Chris Egerter
  3.  
  4. Introduction:
  5. -------------
  6.     While the WGT Sprite Editor was designed for use with the
  7. WordUp Graphics Toolkit, there is no reason why you cannot load the
  8. files into other graphics modes and use them with other graphics
  9. libraries.  This set of utility programs provide an easy solution
  10. to converting WGT Sprite Files.  
  11.  
  12. With this set of conversion programs, the WGT Sprite Files act as a
  13. standard format.  Other graphics libraries may convert a WGT Sprite
  14. File into their own format, but not vice-versa.  For this reason,
  15. a library of sprite images should be kept in the WGT format, and
  16. users will be able to convert them into any other library as they wish.
  17.  
  18. The following is a list of libraries supported, along with their
  19. authors in brackets.
  20.  
  21.    * BGI C version (Borland Graphics Interface)
  22.    * BGI Pascal version (Borland Graphics Interface)
  23.    * Xlib C version (by Themie Gouthas)
  24.    * FastGraph 256 color C version (by Ted Gruber)
  25.    * FastGraph 16 color C version (by Ted Gruber)
  26.    * GameTP (by Scott Ramsay)
  27.    * AniVGA (by Kai Korbacher)
  28.    * The Graphics Engine (by Matthew Hildebrand)
  29.  
  30.  
  31. The Sprite File Format:
  32. -----------------------
  33. The WGT Sprite File contains one palette, and a number of bitmapped 
  34. images.  Here is the format of the sprite files:
  35.  
  36.        1 integer         : Version number (Latest is 4)
  37.        13 bytes          : contains " Sprite File " (with spaces at ends)
  38.        768 unsigned char : palette info
  39.        1 integer         : max number of sprites in file
  40.                Version 4.0 is 2000
  41.                Version 3.5 is 1000
  42.                <3.5 is 200
  43.  
  44.        if VERSION = 4, startspr = 0
  45.          else startspr = 1
  46.        sprite structures { (startspr to max sprite)
  47.        1 integer: sprite made (0 or 1)
  48.        if sprite is made (==1), then read in (block format)
  49.          {
  50.          2 integers         : width and height
  51.          width*height bytes : image data
  52.          }
  53.        end        
  54.  
  55.  
  56. Since the image data is one byte per pixel, each pixel can have a 
  57. value of 0-255, which is its color.  The best way to convert a
  58. file to any mode is to let the graphics library initialize the
  59. mode, and plot individual pixels in each sprite.  This relies on the
  60. library functions only, so it may be ported to any library ever written!
  61. The only requirements are the library has the following commands:
  62.  
  63.     putpixel
  64.     getimage (grabs a portion of the screen into system ram)
  65.     putimage (puts an image from system ram to video ram)
  66.     setpalette (if you have modified the colors)
  67.  
  68. These are extremely basic functions, and all libraries should have them.
  69. The utility programs are meant to be used in the middle of the 
  70. development stage, and not during the actual program execution.
  71. Since the conversion programs draw each image pixel by pixel, running
  72. them within your main program would be slow and unpractical.
  73. If you wish to make your program run in various graphics modes, you
  74. should keep different sprite files, one for each mode.  These should
  75. be converted ahead of time, and can simply be loaded in depending on
  76. which mode you choose.
  77.  
  78.  
  79. With this idea in mind, I have created a generic conversion program which
  80. uses the BGI libraries which are included with all Borland programming
  81. languages.   If you are using a library which does not have a conversion
  82. program in this set, use the spr2bgi program as a template and modify
  83. the graphics commands as needed.  If you are writing a new graphics
  84. library yourself, please send your modified conversion program to me,
  85. so I may include it in the next release of the WGT Sprite Editor.
  86.  
  87.  
  88. Dealing with Palettes:
  89. ----------------------
  90. Palettes become a little tricky when converting a 256 colour image
  91. to an image with lesser colours, for example VGA 640x350 16 colour mode.
  92. Some modes do not allow you to change the palette at all.  If you know
  93. ahead of time which mode you will be using, set the first colours
  94. of the palette to match the ones available in your graphics mode.
  95. You can then draw your images using only the available colours.
  96. In this situation, your graphics will appear exactly as drawn.  In the
  97. VGA 16 colour modes, you may modify the palette.  In EGA modes, you
  98. cannot change the red,green, and blue values of the palette.  For this
  99. reason, you should use the 'standard.pal' file as the palette. This 
  100. contains the default colours for EGA and VGA modes.  
  101.  
  102. If you have drawn your images with 256 colours, and wish you use them
  103. in a mode with less colours, you must first remap the sprites with the
  104. palette with fewer colours.  To do this, see the remap sprites tool
  105. in the Sprite Editor documentation.  To remap your sprites to a 16 color
  106. palette, set the first 16 colors to the normal palette for that mode, and
  107. set the rest to black.  This will ensure that any colors >15 will not be
  108. used.  You should also set colors 252-255 which are normally reserved by
  109. the Sprite Editor as shades of grey.  To set them, hold down the ALT key
  110. while on the 4 colors in color selector.
  111.  
  112.  
  113.